using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace WPCoco
{
    public static class Texture2DExtensions
    {
        public static int GetPixelSize(this Texture2D texture) 
        {
            if (texture == null) return 0;
            switch (texture.Format)
            {
                case SurfaceFormat.Alpha8: 
                    return 1;
                case SurfaceFormat.Bgr565:
                case SurfaceFormat.Bgra4444:
                case SurfaceFormat.Bgra5551:
                case SurfaceFormat.HalfSingle:
                case SurfaceFormat.HdrBlendable:
                case SurfaceFormat.NormalizedByte2:
                case SurfaceFormat.Single:
                    return 2;
                case SurfaceFormat.Color:
                case SurfaceFormat.HalfVector2:
                case SurfaceFormat.NormalizedByte4:
                case SurfaceFormat.Rg32:
                case SurfaceFormat.Rgba1010102:
                    return 4;
                case SurfaceFormat.Dxt1:
                case SurfaceFormat.Dxt3:
                case SurfaceFormat.Dxt5:
                    return -1;
                case SurfaceFormat.HalfVector4:
                case SurfaceFormat.Rgba64:
                case SurfaceFormat.Vector2:
                    return 8;
                case SurfaceFormat.Vector4:
                    return 16;
                default:
                    return 0;
            }
        }

    }
}
